feat(csp): expand tree-sitter coverage via tree-sitter-language-pack - #39
Merged
amondnet merged 2 commits intoJun 20, 2026
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #38. The Rust chunker resolved grammars through a curated ~14-grammar static set (
language_for), so files in recognized-but-uncurated languages (kotlin, swift, php, scala, lua, …) were walked and indexed but fell through to line chunking instead of AST chunking — a real behavioral narrowing vs upstream semble, which usestree_sitter_language_pack(≈all languages).This swaps the curated set for the Rust
tree-sitter-language-packcrate (306 grammars, full upstream parity — the Rust sibling of the package semble itself uses). 264 of csp's 265EXTENSION_TO_LANGUAGEnames now AST-chunk; onlywolframlacks a pack grammar.Changes
language_for→tree_sitter_language_pack::get_language(name).ok()— downloads the parser from GitHub releases on first use, caches it on disk; unknown language or offline fetch failure →None→ line fallback (the prior degradation contract, unchanged).is_supported_language→has_language(name)— a metadata-only lookup (no download), sochunk_sourcegates AST chunking cheaply before paying for a fetch.tree-sitter-*crates withtree-sitter-language-pack = "1.9".tree-sitterstays a direct dep and resolves to the same0.26.x(ABI-compatibleLanguage).semble.md§4.3/§4.5/§6.2 updated.Trade-off (decided with maintainer, ADR-0004)
The
cspbinary stays a single executable, but AST chunking is no longer fully offline/self-contained — grammars fetch from GitHub releases on first use and cache under the OS cache dir. Degradation is graceful (offline → line chunking, exactly what an unsupported language already did) and no language regresses below prior behavior. Binary shrinks (no compiled-in grammars).Test plan
cargo fmt --all✅ ·cargo clippy --all-targets --all-features -- -D warnings✅ ·cargo test --workspace✅ (256 + 8 passed, 4 ignored)has_language) + fallback assertions run in the default suite.#[ignore]d (need network to download a grammar). Verified locally:Acceptance criteria (#38)
Some(Language)fromlanguage_forand AST-chunk (verified bynewly_supported_languages_are_ast_chunked).semble.md§6.2 item updated/closed.Summary by cubic
Switches the Rust chunker to
tree-sitter-language-packfor near-full grammar coverage; 264/265 recognized languages now AST-chunk instead of lines. Parsers download on first use and cache on disk, with one-time warnings on grammar load failures and graceful line fallback when offline.New Features
tree_sitter_language_pack::get_language(name);is_supported_languageuseshas_language(name)(metadata-only, no download).wolframinEXTENSION_TO_LANGUAGEstill line-chunks.None+ one-time stderr warning per language → line fallback.ignored-testsjob (manual/weekly) to run real parse tests that download grammars.Dependencies
tree-sitter-*crates withtree-sitter-language-pack = "1.9";tree-sitterremains (0.26.x ABI-compatible).Written for commit 60530fd. Summary will update on new commits.
Summary by CodeRabbit
Documentation
Refactor
Tests